<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
  
	<!--添加需要搜索的工具  -->
	<div id="huotb11" style="padding: 5px; height: auto">
		<div>
			<a id="huoadd11" href="javascript:void(0)" class="easyui-linkbutton"
				data-options="iconCls:'icon-add',plain:true">添加</a>
				<a href="javascript:void(0)" class="easyui-linkbutton"
				data-options="iconCls:'icon-remove',plain:true" onclick="removeit()">删除</a>
				<a href="javascript:void(0)" class="easyui-linkbutton"
				data-options="iconCls:'icon-edit',plain:true" onclick="huoedit()">编辑</a>
			 <sapn style="margin-left:50%">搜索文本：</sapn> <input id="holidayname" class="easyui-searchbox easyui-numberbox" data-options="searcher:searchname,prompt:'请输入需要搜索的员工编号'"
				style="width: 20%">
		</div>
	</div>
	<table id="huodg11" class="easyui-datagrid"></table>
	<!-- 弹出新增窗口代码开始 -->
	<div id="huodd11" class="easyui-dialog"
		style="width: 600px; height: 300px"
		data-options="modal:true,closed:true,title:'添加假种信息'">
		<form id="ff" method="post" action="addemp">
			<div id="holidaybody" style="margin: 2% 20%">
			<input class="easyui-textbox " type="text" style="display:none;width:10px;" id="withcardId"/>
			<input class="easyui-textbox " type="text" style="display:none; width:10px;" id="maker"/>
			<input class="easyui-textbox " type="text" style="display:none; width:10px;" id="makeTime"/><br>
				<label for="holidayName">员工编号:</label> 
				<input class="easyui-combobox holidaytext" type="text" id="empId"/><br>
				<label for="holidayName">账套编号:</label> 
				<input class="easyui-combobox holidaytext" type="text" id="accountId"/><br>
				 <div>生效日期:<input id="effectivaDate" class="easyui-datebox holidaytext"><br></div>  
			     <div>失效日期:<input id="expiryDate" class="easyui-datebox holidaytext"><br></div>
			</div>
		</form>
	</div>
  <script src="../hyn/js/check/checkWithCard.js"></script>
	<script type="text/javascript">
		$("#huoadd11").linkbutton({
			onClick : function() {
				$("#huodd11").window("open");
			}
		});
    
		$("#effectivaDate").datebox({});
	    $("#expiryDate").datebox({});
		 $('#empId').combobox({
			url:'../check/getemp',
			valueField:'empId',
			textField:'empId',
			panelHeight:'auto'
			});
			
			$('#accountId').combobox({
			url:'../card/getCheckAccounts',
			valueField:'accountId',
			textField:'accountId',
			panelHeight:'auto'
			});	
		// 定义底部保存，清空，取消按钮
		$('#huodd11').dialog({
			buttons : [ {
				text : '保存',
				iconCls : 'icon-save',
				handler : function() {
					$('#ff').form('submit', {
						onSubmit : function(param) {
							var withcardId= $("#withcardId").val();
							var empId = $("#empId").val();
							var accountId =$("#accountId").val();
							var remark = $("#remark").val();
							var effectivaDate=$("#effectivaDate").val();
							var expiryDate=$("#expiryDate").val();
							var withcardIds = [];
/* 							confirm(expiryDate); */
							if(withcardId==null||withcardId===''){
								var maker = "huohuo"/* ${user} */;
								var withcardId = {
										withcardId: empId,
										empId : empId,
										accountId : accountId,
										remark : remark,
										effectivaDate : effectivaDate,
										expiryDate : expiryDate,
										maker : maker	
									};
								     withcardIds.push(withcardId);
									var jsondata = JSON.stringify(withcardIds);
								$.ajax({
									url : "../card/addCheckWithCard",
									data : {"jsondata" : jsondata},
									success : function(e) {
										if (e == "ok") {
											alert("存储成功");
			                               $('#huodg11').datagrid('load');
										}
									}
								});
							}
							else{
								var maker = $("#maker").val();	
								var makeTime = $("#makeTime").val();
								var updateEmp =  "huohuo"/* ${user} */;
								var withcardId = {
										withcardId: withcardId,
										empId : empId,
										accountId : accountId,
										remark : remark,
										effectivaDate : effectivaDate,
										expiryDate : expiryDate,
										maker : maker, 
										makeTime:makeTime,
										updateEmp:updateEmp
									};
								    withcardIds.push(withcardId);
									var update_jsondata = JSON.stringify(withcardIds);
								$.ajax({
									url : "../card/updateCheckWithCard",
									data : {"update_jsondata" :update_jsondata},
									success : function(e) {
										if (e == "ok") {
											alert("修改成功");
			                               $('#huodg11').datagrid('load');
										}
									}
								});
							}
						},
						success : function(data) {

						}
					});
				}
			}, {
				text : '清空',
				iconCls : 'icon-clear',
				handler : function() {
					$('#ff').form('clear');
				}
			}, {
				text : '取消',
				iconCls : 'icon-cancel',
				handler : function() {
					$("#huodd11").window("close");
				}
			} ]
		});
		function huoedit(){
			var rows = $('#huodg11').datagrid('getSelected');
			if(rows.withcardId!=null||rows.withcardId==""){
				$("#withcardId").val(rows.withcardId);
				$("#empId").val(rows.emp.empId);
				$("#empName").val(rows.empName);
				$("#accountId").val(rows.checkAccount.accountId);
				$("#effectivaDate").val(rows.effectivaDate);
				$("#expiryDate").val(rows.expiryDate);
				$("#maker").val(rows.maker);
				$("#makeTime").val(rows.makeTime);
				$("#huodd11").window("open");
			}else{
				alert("未勾选数据");
			}
	}
	</script>
	<!-- 弹出新增窗口代码结束 -->
</body>
</html>